#!/bin/sh
#  
#  This file is part of JunOS Operating System.
#  
#  Copyright (C) 2016, Liu Xiaofeng <lxf.junos@aliyun.com>
#  Licensed under MIT, http://opensource.org/licenses/MIT. 
#

mkdir -p tmp/iso/boot/grub

test  -f tmp/iso/boot/grub/grub.cfg || echo '
set default=0
set timeout=5

menuentry "JunOS (CD)" {
	insmod minix
	multiboot2 (cd)/vmjunos
	module2    (cd)/none
	module2    (cd)/ramdisk
	boot
}

menuentry "JunOS (HD)" {
	insmod minix
	multiboot2 (hd0)/vmjunos
	module2    (hd0)/none
	module2    (hd0)/ramdisk
	boot
}
' > tmp/iso/boot/grub/grub.cfg

test -f tmp/iso/none || dd if=/dev/zero of=tmp/iso/none bs=1M count=1 2> /dev/null

cp kernel/kernel.bin  tmp/iso/vmjunos

echo "Creating cdrom.iso ..."
grub-mkrescue -o tmp/cdrom.iso tmp/iso 2> /dev/null

if [ ! $? ]; then
	echo "Error: create cdrom.iso failed !"
fi
